unit Unit53; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, Unit1;

type

  { TForm53 }

  TForm53 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    ComboBox1: TComboBox;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormShow();
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  Form53: TForm53; 

implementation

{ TForm53 }

procedure TForm53.Button2Click(Sender: TObject);
begin
  Close;
end;

procedure TForm53.Button1Click(Sender: TObject);
var
  QueryString : string;
  
begin
  if Edit1.Text <> '' then
  begin
    QueryString := 'insert into sucursal(suc_nombre, suc_descripcion) values('''
      + Edit1.Text + ''', ''' + ComboBox1.Text + ''')';
      
    Form1.PQConnection1.ExecuteDirect('begin work;');
    Form1.PQConnection1.ExecuteDirect(QueryString);
    Form1.PQConnection1.ExecuteDirect('commit work;');
    
    ShowMessage('ALTA EXITOSA');
    
    FormShow();
  end
  else
    ShowMessage('INGRESO DE DATOS INCORRECTO');
end;

procedure TForm53.FormShow();
begin
  Edit1.Text := '';
  ComboBox1.Text := '';
  
  Edit1.SetFocus;
end;

initialization
  {$I unit53.lrs}

end.

